<?php 
header("Content-type: text/html; charset=utf-8");
/**
 * [CF 格式存储单位]
 * @Author   Xuebingsi
 * @DateTime 2017-03-07T11:13:44+0800
 * @param    [int]                   $size [字节]
 */
function CF($size)
{
	if($size>pow(1024,3)){
	    return round($size/pow(1024,3),2)."GB";
	}elseif($size>pow(1024,2)){
		return	round($size/pow(1024,2),2)."MB";
	}elseif($size>pow(1024,1)){
		return round(($size/1024),2)."KB";
	}else{
		return $size."B";
	}
}

/**
 * [runTime 脚本计算时间]
 * @Author   Xuebingsi
 * @DateTime 2017-03-07T11:14:28+0800
 * @param    string                   $end [结果调用传入]
 * @return   [type]                        [description]
 *脚本开始时执行 runTime();
 *脚本结束前执行 runTime('end')
 * 
 */
function runTime($end='')
{
	static $startTime;

	if(empty($end)){
		$startTime = microtime(true);
	}else{
		echo microtime(true)-$startTime;
	}

}
/**
 * [CT 时间转换]
 * @Author   Xuebingsi
 * @DateTime 2017-03-08T08:56:40+0800
 * @param    [int]                   $time [时间戳]
 */
function CT($time)
{
	$diff = time()-$time;
	if($diff<60){
		return "刚刚";
	}elseif($diff<3600){
		return round($diff/60)."分钟之前";
	}elseif($diff<86400){
		return round($diff/60/60)."小时之前";
	}elseif($diff<(86400*7)){
		return round($diff/86400)."天之前";
	}else{
		return date('Y-m-d H:i:s',$time);
	}
}

/**
 * [liuHecai 随机产生一定个数方法]
 * @Author   Xuebingsi
 * @DateTime 2017-03-08T08:57:31+0800
 * @param    integer                  $satrt [随机开始值]
 * @param    integer                  $end   [随机结束值]
 * @param    integer                  $num   [随机的个数]
 * @return   [array]                          [数组]
 */
function liuHecai($satrt=1,$end=47,$num=6)
{
	$data =array();
	for ($i=0; $i < $num; $i++) { 
		$res = mt_rand($satrt,$end);
		if(in_array($res, $data)){
			$i--;
			continue;
		}else{
			array_push($data, $res);
		}
		
	}
	return $data;
}

function test()
{
	# code...
}


/**
 * [error description]
 * @Author   Xuebingsi
 * @DateTime 2017-03-16T10:57:59+0800
 * @return   [type]                   [description]
 */
function error($info,$url='./index.php',$time=4)
{
	$error=1;
	include_once './Tpl/info.html';
}
/**
 * [success description]
 * @Author   Xuebingsi
 * @DateTime 2017-03-16T10:57:59+0800
 * @return   [type]                   [description]
 */
function success($info,$url='./index.php',$time=4)
{
	include_once './Tpl/info.html';
}






















 ?>